package com.computergames.server.service.Implement;

import com.computergames.server.dao.UserDao;
import com.computergames.server.message.LoginRequestMessage;
import com.computergames.server.service.Interface.UserService;
import com.computergames.server.util.SpringUtil;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    private UserDao userDao;

    @Override
    //根据客户端传来的用户名密码查询数据库
    public LoginRequestMessage findUser(LoginRequestMessage user)
    {
        userDao = SpringUtil.getBean(UserDao.class);
        return userDao.findUser(user);
    }

    @Override
    public int findUserId(String username)
    {
        userDao = SpringUtil.getBean(UserDao.class);
        return userDao.findUserId(username);
    }

    @Override
    public String getStoredHashedPassword(String username) {
        userDao = SpringUtil.getBean(UserDao.class);
        return userDao.findPasswordByUsername(username);
    }

}
